#pragma once
#include <QtCore/QObject> 
#include <iostream>
#include <chrono>
#include <cmath>
#include "cuda_utils.h"
#include "logging.h"
#include "common.hpp"
#include "utils.h"
#include "calibrator.h"
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#define NMS_THRESH 0.45
#define CONF_THRESH 0.1

static const int OUTPUT_SIZE = Yolo::MAX_OUTPUT_BBOX_COUNT * sizeof(Yolo::Detection) / sizeof(float) + 1;  // we assume the yololayer outputs no more than MAX_OUTPUT_BBOX_COUNT boxes that conf >= 0.1


class ModelDetectProc :public QObject {
	Q_OBJECT
public:
	ModelDetectProc();
	~ModelDetectProc();

signals:
	void modelDetectFileCount(int);
signals:
	void modelDetectCurrValue(int);
signals:
	void modelDetectComplete(bool);

public slots :
	void onSetInput_H(int _inputH);
	void onSetInput_W(int _inputW);
	void onSetBatchSize(int _batchSize);

	void onModelDetect(std::string engine_name, std::string imgsPath, std::string saveImgsPath);

private:
	void doInference(IExecutionContext& context, cudaStream_t& stream, void **buffers, float* input, float* output, int batchSize);

private:
	std::string input_blob_name_;
	std::string output_blob_name_;
	Logger gLogger;

	int batchSize;
	int input_imgH;
	int input_imgW;

};